package org.yefei.homeworkday22;

public class Six {

	public static void main(String[] args) {
		/*
		 * 6、传闻StringBuilder比StringBuffer快,String最慢， 比较一下，输出你的比较结果（拼接10万个字符串，比较时间；做5次）
		 */
		long start1 = System.nanoTime();
		String str = "我是：";
		for (int i = 0; i < 100000; i++) {
			str = str.concat("蔡徐坤");
		}
		long end1 = System.nanoTime();
		System.out.println("String:" + (end1 - start1));

		long start2 = System.nanoTime();
		StringBuffer s = new StringBuffer("我是：");
		for (int i = 0; i < 100000; i++) {
			s.append("蔡徐坤");
		}
		long end2 = System.nanoTime();
		System.out.println("StringBuffer:" + (end2 - start2));

		long start3 = System.nanoTime();
		StringBuilder ss = new StringBuilder();
		for (int i = 0; i < 100000; i++) {
			ss.append("蔡徐坤");
		}
		long end3 = System.nanoTime();
		System.out.println("StringBuilder:" + (end3 - start3));
	}
}
